# -*- encoding: utf-8 -*-

from memory import ESP

class Push(object):

    """ Classe définissant une instruction Push Ra. """

    def __init__ (self, ra, mem):
        self.__ra = ra
        self.__mem  = mem

    def do (self):
        esp = self.__mem.getRegister(ESP)
        self.__mem.setRegister(ESP, esp - 1)
        self.__mem.setRamAt(
            addr = esp - 1,
            newVal = self.__mem.getRegister(self.__ra)
            )

    def __str__ (self):
        return "push r{0:d}".format(self.__ra) 

    def __unicode__ (self):
        return self.__str__ () 
